home *** CD-ROM | disk | FTP | other *** search
/ Champak 52 / Volume 52 - JOGO DISK .iso / Games / shopdrop.swf / scripts / __Packages / Crossfader.as < prev    next >
Text File  |  2007-09-27  |  2KB  |  71 lines

  1. class Crossfader extends MovieClip
  2. {
  3.    var topVol = 60;
  4.    var crossFrames = 15;
  5.    var direction = -1;
  6.    function Crossfader()
  7.    {
  8.       super();
  9.       this.cVol = this.topVol;
  10.       this.volInc = this.topVol / this.crossFrames;
  11.       this.oSoundOne = this.mcOne.oSound = new Sound(this.mcOne);
  12.       this.oSoundTwo = this.mcTwo.oSound = new Sound(this.mcTwo);
  13.       this.oSoundOne.setVolume(this.topVol);
  14.       this.oSoundTwo.setVolume(0);
  15.    }
  16.    function updateFade()
  17.    {
  18.       this.cVol += this.direction * this.volInc;
  19.       this.oSoundOne.setVolume(this.cVol);
  20.       this.oSoundTwo.setVolume(this.topVol - this.cVol);
  21.       if(this.direction == -1)
  22.       {
  23.          if(this.cVol <= 0)
  24.          {
  25.             this.direction = 1;
  26.             this.onEnterFrame = null;
  27.          }
  28.       }
  29.       else if(this.cVol >= this.topVol)
  30.       {
  31.          this.direction = -1;
  32.          this.onEnterFrame = null;
  33.       }
  34.    }
  35.    function crossFade()
  36.    {
  37.       this.onEnterFrame = this.updateFade;
  38.    }
  39.    function fadeToOne()
  40.    {
  41.       if(this.direction == 1)
  42.       {
  43.          this.crossFade();
  44.       }
  45.    }
  46.    function fadeToTwo()
  47.    {
  48.       if(this.direction == -1)
  49.       {
  50.          this.crossFade();
  51.       }
  52.    }
  53.    function playMusic()
  54.    {
  55.       this.mcOne.play();
  56.       this.mcTwo.play();
  57.    }
  58.    function stopMusic()
  59.    {
  60.       this.oSoundOne.stop();
  61.       this.oSoundTwo.stop();
  62.    }
  63.    function reset()
  64.    {
  65.       this.direction = -1;
  66.       this.cVol = this.topVol;
  67.       this.oSoundOne.setVolume(this.topVol);
  68.       this.oSoundTwo.setVolume(0);
  69.    }
  70. }
  71.